﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using DLM.Infrastructure.Domain;

namespace DLM.Domain.Model
{
    public class Modality : IValidatableObject, IAggregateRoot
    {
        public Modality()
        {
            this.Supplier = new HashSet<Supplier>();
        }

        public int MID { get; set; }

        [Required(ErrorMessage="活动编号不允许为空")]
        public int PID { get; set; }

        [Required(ErrorMessage="活动形式名称不允许为空")]
        [StringLength(20,ErrorMessage="最大长度为20")]
        public string Name { get; set; }

        public virtual Type PartyType { get; set; }

        public virtual ICollection<Supplier> Supplier { get; set; }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (string.IsNullOrEmpty(Name))
            {
                yield return new ValidationResult("活动形式名称不允许为空", new string[] {"Name" });
            }
        }
    }
}
